/**
 * @file       PageInfo.h
 * @brief      A class to handler paging
 * @author     Huabo Zheng
 * @date       Jan 31, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#ifndef PAGEINFO_H_
#define PAGEINFO_H_

#include "Object.h"
#include <map>

namespace NS_LCD_AFW
{

/**
 *NS_LCD_AFW::CPageInfo
 */

/**
 *@class  CPageInfo
 *@brief   A class to handler paging
 */
class CPageInfo: public NS_LCD_AFW::CObject
{
public:

	/**
	 * @enum Direction
	 * @brief Key directions
	 */
	enum Direction
	{
		UNKNOW,
		UP,
		DOWN,
		RIGHT,
		LEFT
	};
public:

	/**
	 *@brief Constructor
	 */
	CPageInfo();

	/**
	*@brief DeConstructor
	*/
	virtual ~CPageInfo();

	/**
	 *@brief  Get current page NO
	 *@details Get current page NO
	 *@exception none
	 *@retval    int
	 *@return    Current page NO
	 *@note
	 *@attention
	 *@see
	 *@see
	*/
	int getCurPage() const;

	/**
	 *@brief  Get the last object index of current page
	 *@details  Get the last object index of current page
	 *@exception none
	 *@retval    int
	 *@return    the last object index of current page
	 *@note
	 *@attention
	 *@see
	 *@see
	*/
	int getEndIndex() const;

	/**
	 *@brief  Get the hightlight object index of current page
	 *@details  Get the hightlight object index of current page
	 *@exception none
	 *@retval    int
	 *@return    the hightlight object index of current page
	 *@note
	 *@attention
	 *@see
	 *@see
	*/
	int getHightLightObjIndex() const;

	/**
	 *@brief  Get the first object index of current page
	 *@details  Get the first object index of current page
	 *@exception none
	 *@retval    int
	 *@return    the first object index of current page
	 *@note
	 *@attention
	 *@see
	 *@see
	*/
	int getStartIndex() const;

	/**
	 *@brief  Get the total number of pages
	 *@details Get the total number of pages
	 *@exception none
	 *@retval    int
	 *@return    the total number of pages
	 *@note
	 *@attention
	 *@see
	 *@see
	*/
	int getTotalPage() const;

	/**
	 *@brief  Get current Direction
	 *@details  Get current Direction
	 *@exception none
	 *@retval    Direction
	 *@return    key direction
	 *@note
	 *@attention
	 *@see
	 *@see
	*/
	Direction getDirection() const;

	/**
	 *@brief  Determine whether need to switch the page
	 *@details   Determine whether need to switch the page
	 *@exception none
	 *@retval    bool
	 *@return    true if necessary,otherwise false
	 *@note
	 *@attention
	 *@see
	*/
	bool isNeedSwitchPage() const;

	/**
	 *@brief  setNeedSwitchPage
	 *@details
	 *@param[in]  bNeedSwitchPage true if need to switch
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setNeedSwitchPage(bool bNeedSwitchPage);


	/**
	 *@brief  set current page NO
	 *@details Jump to the specified page
	 *@param[in]  iCurPage page NO
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setCurPage(int iCurPage);


	/**
	 *@brief  set the HightLightObj Index in current page
	 *@details set the HightLightObj Index in current page
	 *@param[in]  iHightLightObjIndex hightlight object index
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setHightLightObjIndex(int iHightLightObjIndex);

	/**
	 *@brief  To check if it's the valid index of the hightlight object
	 *@details To check if it's the valid index of the hightlight object
	 *@exception none
	 *@retval    bool
	 *@return    true if valid,otherwise false
	 *@note
	 *@attention if the hightlight object index greater or equal startindex and less then endindex,it's a valid index;
	 *@see
	*/
	bool isValidHightLightObjIndex() const;

	/**
	 *@brief  Set the total number of pages
	 *@details Set the total number of pages
	 *@param[in] iTotalPage the total number of pages
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setTotalPage(int iTotalPage);

	/**
	 *@brief  setDirection
	 *@details setDirection
	 *@param[in] eDirection
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setDirection(Direction eDirection);

	/**
	 *@brief  set up page info
	 *@details set up page info
	 *@param[in] pageNo   current page NO
	 *@param[in] startIndex  the startindex of current page
	 *@param[in] endIndex    the endindex of current page
	 *@exception none
	 *@retval    void
	 *@return    none
	 *@note
	 *@attention
	 *@see
	*/
	void setPageInfo(int pageNo, int startIndex, int endIndex);
private:
	bool isNeedUpdateView() const;
	void setNeedUpdateView(bool bNeedUpdateView);
public:
	struct TPageIndex
	{
		int iStartIndex;
		int iEndIndex;
	};
	typedef std::map<int, TPageIndex> TPageIndexMap;
private:
	int m_iHightLightObjIndex;
	int m_iTotalPage;
	int m_iCurPage;
	Direction m_eDirection;
	bool m_bNeedSwitchPage;
	bool m_bNeedUpdateView;
	TPageIndexMap m_pageIndexMap;
};

} /* namespace NS_LCD_AFW */
#endif /* PAGEINFO_H_ */
